<?php
include_once '../Login/databaseconnection.php';
  $P_Id=$_SESSION['P_Id'];
	    $S_Id=$_SESSION['S_Id'];
	    $year=$_SESSION['year'];
		$Grade=$_SESSION['Grade'];
		
		$_SESSION['Pr_Id']=$_SESSION['P_Id'];
	    $_SESSION['Sc_Id']=$_SESSION['S_Id'];
	    $_SESSION['yea']=$_SESSION['year'];
		$_SESSION['gra']=$_SESSION['Grade'];
		$Required_Teachers=$_POST['Required_Teachers'];
		$P_Id1=$_POST['Pro_Id'];
	   $S_Id1=$_POST['Sch_Id'];
	   $Grade1=$_POST['Grade'];
	   $year1=$_POST['Year'];
	  $No_F_Stu=$_POST['No_Of_Female_Students'];
    $No_M_Stu=$_POST['No_Of_Male_Students'];
   $No_Tra_tea=$_POST['Teachers_In_Training'];
    $Tra_tea=$_POST['Trained_Teachers'];
    $Avai_Book=$_POST['Avai_Book'];
 $Avai_Tea_Gui=$_POST['Avai_Tea_Gui'];
 date_default_timezone_set("Europe/Paris");
    $t_d=date("Y/m/d");
   
   if($P_Id==null)
   {
	   echo "null";
   }
   if($No_M_Stu==""||$No_F_Stu==""||$No_Tra_tea==""||$Tra_tea==""||$Required_Teachers==""||$Avai_Book==""||$Avai_Tea_Gui==""||$year1==""||$P_Id1==""||$S_Id1==""||$Grade1=="")
	{
		   $_SESSION['errorin']="Please check your inputs some of them are null!";	 
	}
	else
	{	
$sql=mysql_query("UPDATE programmes SET Grade='$Grade1',Required_Teachers='$Required_Teachers',Programme_Id='$P_Id1',Year='$year1',School_Id='$S_Id1',No_Of_Male_Students='$No_M_Stu',No_Of_Female_Students='$No_F_Stu',Teachers_In_Training='$No_Tra_tea',Trained_Teachers='$Tra_tea',Availability_Books='$Avai_Book',Availability_Tguides='$Avai_Tea_Gui',Last_Updated_Date='$t_d' WHERE Programme_Id='$P_Id' AND Year='$year' AND School_Id='$S_Id'");

unset($_SESSION['P_Id']);
unset($_SESSION['S_Id']);
unset($_SESSION['year']);
if(mysql_affected_rows()!=0)
  {
$_SESSION['error']="Successfully updated!";

  }

 if(mysql_affected_rows()==0)
  {
 $_SESSION['error']="Sorry unable to update this record!";
  }
	
}
  ?>
